<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增【预约】')" />
    <th:block th:include="include :: datetimepicker-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-experiment-add">
        <div class="form-group" hidden="hidden">
            <label class="col-sm-3 control-label">在线实验id：</label>
            <div class="col-sm-8">
                <input name="onlineExperimentId" th:value="${onlineExperimentId}" class="form-control">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">预约开始时间：</label>
            <div class="col-sm-8">
                <input name="beginTime" id="beginTime" class="form-control" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">预约结束时间：</label>
            <div class="col-sm-8">
                <input name="endTime" id="endTime" class="form-control" type="text" required>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: datetimepicker-js" />
<script type="text/javascript">
    var prefix = ctx + "/system/onlineExperimentOrder"

    $("#form-experiment-add").validate({
        onkeyup: false,
        rules: {
            beginTime: {
                required : true,
            },
            endTime: {
                required : true,
            },
        },
        messages: {
            beginTime: {
                required : "开始日期必填"
            },
            endTime: {
                required: "结束日期必填"
            },
        },
        focusCleanup: true
    });


    $("#beginTime").datetimepicker({
        format: 'yyyy-mm-dd',
        minView: 2,
        autoclose: true, //选择后自动关闭
        todayBtn: true,  //显示今天按钮
    })
    $("#endTime").datetimepicker({
        format: 'yyyy-mm-dd',
        minView: 2,
        autoclose: true, //选择后自动关闭
        todayBtn: true,  //显示今天按钮
    })

    function submitHandler() {
        if ($.validate.form()) {
            if($("#endTime").val()<=$("#startTime").val()){
                $.modal.msgError("预约结束时间不能小于开始时间")
            }else{
                $.operate.save(prefix + "/add", $('#form-experiment-add').serialize());
            }
        }
    }
</script>
</body>
</html>